<template>
    <h2>登录</h2>
    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="Name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="text" v-model="Pass">
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" @click="Login">
            </td>
        </tr>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const Name = ref('');
const Pass = ref('');
const router = useRouter();
const Login = () => {
    axios.get('http://localhost:25825/api/Demo/Login', {
        params: {
            Name: Name.value,
            Pass: Pass.value
        }
    })
        .then(res => {
            if (res.data != null) {
                alert("登录成功");
                router.push('/Show')
                return;
            }
            else {
                alert("用户名或密码错误");
                return;
            }
        })
}

</script>